<?php

!defined('IN_NOVA') && exit('Access Denied!');

class Page {

	private $page;

	function __set( $name, $value ) {
		$this->page[$name] = $value;
	}

	function __get( $name ) {
		//[DEBUG]
		global $log;
		//[/DEBUG]
		if( !isset( $this->page[$name] ) ) {
			//[DEBUG]
			if( defined( 'APP_DEBUG' ) && APP_DEBUG === TRUE ) {
				$log->add( '[' . __FILE__ . '] [' . __LINE__ . '] ' . L( '_USE_ILLEGAL_INDEX_' ) . ' ' . $name, E_USER_NOTICE );
			}
			//[/DEBUG]
			return NULL;
		}
		return $this->page[$name];
	}

	public function start() {
		global $theme,$cache,$request,$db;
		$alias = $theme->name = $this->name;
		$result = $db->fetch_one_array( "SELECT * FROM `" . DB_PREFIX . "article` WHERE address='{$alias}' AND isdel=0 AND type=3" );
		if( !$result ) {
			$theme->err_404();
			return;
		}
		foreach( $result as $key => $value ) {
			$theme->$key = $value;
		}
		$theme->load( 'read' );
	}

}
?>
